package com.hyh.admin.recommend;

import com.hyh.ad.common.core.redis.CacheClient;
import com.hyh.ad.common.core.redis.RedisCache;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserProfileService {
    @Autowired
    private CacheClient cacheClient;

    /**
     * 存储用户画像
     */
    public void saveUserProfile(UserProfile userProfile) {
        cacheClient.setWithoutTime("user_profile:" + userProfile.getUser().getId(), userProfile);
    }

    /**
     * 获取用户画像
     */
    public UserProfile getUserProfile(String userId) {
        return cacheClient.getObject("user_profile:" + userId, UserProfile.class);
    }
}

